<template>
  <BaseChart ref="childRef" :option="options" class="chartMainContent"></BaseChart>
</template>
<script setup>
import { nextTick, onMounted, ref, shallowRef, watch } from 'vue'
import BaseChart from '../../../components/baseChart.vue'
const options = shallowRef()
const getBaseOptions = () => {
  return {
    color: ['#23EBC2', '#FAD760', '#00D9FF', '#F77723', '#0099FF'],
    tooltip: {
      trigger: 'item',
      formatter: '{b}：\n{c}%'
    },
    grid: {
      top: '1%',
      bottom: '1%',
      left: '1%',
      right: '1%'
    },
    series: [
      {
        type: 'treemap',
        roam: false, // 是否开启拖拽漫游（移动和缩放）
        nodeClick: false, // 点击节点后的行为,false无反应
        breadcrumb: {
          show: false
        },
        top: 10,
        bottom: 10,
        left: '1%',
        right: '1%',
        label: {
          show: true,
          formatter: '{b}: \n{c}%',
          position: ['4%', '40%']
        },
        itemStyle: {
          show: true,
          textStyle: {
            color: '#fff',
            fontSize: 16
          },
          borderWidth: 1,
          borderColor: '#fff'
        },
        data: [
          {
            value: 50,
            name: '数据一'
          },
          {
            value: 15,
            name: '数据二'
          },
          {
            value: 16.5,
            name: '数据三'
          },
          {
            value: 4.5,
            name: '数据四'
          },
          {
            value: 15,
            name: '数据五'
          }
        ]
      }
    ]
  }
}
onMounted(() => {
  nextTick(() => {
    const option = getBaseOptions()
    options.value = option
  })
})
</script>

<style scoped lang="scss">
.chartMainContent {
  height: 2.7rem;
}
</style>
